Update Readme.md
[EroSomnia.git] / Point and Click Game1 / OpeningSequence.h
blob08fb2862662177b83461dab255c1e829e884b467
1 #pragma once
3 #include <vector>
5 #include "ScreenIncludes.h"
8 namespace OpeningSequence
10 void OpeningSequence(int* screen, SDL_Renderer* r1, SDL_Window* win);
12 void gameLoop();
14 void processInput();
15 void update();
16 void play();
17 void render();
18 void close();
20 bool endTransitionFlag;
21 bool langClicked;
22 bool logo1Flag;
23 bool logo2Flag;
24 bool screenRunning;
25 bool skippedFlag;
28 const int FPS = 30;
30 double fadeRate;
31 DATATYPE_MILLISECONDS systemTime;
33 int alpha;
34 int x;
35 int y;
36 int* screen;
38 long long initial = 0;
39 long long expired = 0;
40 long long start = 0;
41 long long timer = 0;
44 MouseIO* mio;
46 SDL_Renderer* r1;
47 SDL_Window* w1;
49 Texture* engSymbol;
50 Texture* jpSymbol;
51 Texture* logoEC;
53 Texture* logo2;
54 Texture* logo3;
56 std::vector<bool>* inputs;
58 void OpeningSequence::OpeningSequence(int* screen, SDL_Renderer* rend, SDL_Window* win)
60 OpeningSequence::screen = screen;
61 r1 = rend;
62 w1 = win;
64 alpha = 0;
66 mio = new MouseIO();
68 engSymbol = new Texture(SDL_Rect{0,0,Graphics::prcnt(0.1, 'x', w1),Graphics::prcnt(0.1, 'y', w1) }, "Icons/EN.png", r1, w1 );
69 jpSymbol = new Texture(SDL_Rect{ 500,500,Graphics::prcnt(0.1, 'x', w1),Graphics::prcnt(0.1, 'y', w1) }, "Icons/JP.png", r1, w1);
70 gameLoop();
74 void OpeningSequence::gameLoop() {
75 screenRunning = true;
76 systemTime = SYSTEM_MILLISECONDS;
77 initial = 0;
78 expired = 0;
80 while (screenRunning) {
81 systemTime = SYSTEM_MILLISECONDS;
82 initial = systemTime.count();
84 processInput();
85 update();
86 play();
87 render();
89 GenericGameTools::stallGame(&initial, &expired, (int)(1.0 / FPS * 1000));
92 close();
95 void OpeningSequence::processInput() {
96 int x, y;
97 inputs = mio->processMouseInput(&x, &y);
99 screenRunning = !inputs->at(QUIT);
103 void OpeningSequence::update() {
104 if (langClicked) {
105 systemTime = SYSTEM_MILLISECONDS;
106 timer = systemTime.count();
107 int elapsed = timer - start;
109 else if (timer < 123 && timer > -1 ) {
110 logo1Flag = true;
111 alpha = 0;
112 //check skip
114 else if (timer < 456 && timer > -1) {
115 logo2Flag = true;
116 alpha = 0;
117 //check skip
119 else if (timer < 789 && timer > -1) {
120 endTransitionFlag = true;
121 alpha = 0;
122 //if transition reaches a point end the opening screen
123 //check skip
125 else if (timer < 1123 && timer > -1) {
126 screenRunning = false;
128 else if(langClicked){
129 //load respective text
130 alpha = 0;
131 start = timer;
134 if (skippedFlag) {
135 //set end transition flags
136 //set timer to a certain pointer
141 void OpeningSequence::play() {
144 void OpeningSequence::render() {
145 SDL_RenderClear(r1);
147 //if transition flag
148 //if alpha is not at max
149 //fade in
150 //destroy logo2
151 //if logo2 flag
152 //if alpha is not at max
153 //fade in
154 //destroy logo1
155 //if logo1 flag
156 //if alpha is not at max
157 //fade in
158 //destroy symbols
159 //else
160 //if alpha is not at max
161 //fade in
162 engSymbol->renderTexture();
163 jpSymbol->renderTexture();
165 SDL_RenderPresent(r1);
167 void OpeningSequence::close() {
168 *screen = 10;
169 delete engSymbol;
170 delete jpSymbol;